<?php

class get
{
    static function root()
    {
        updateLoginStatus();
        loadHead(ROOT_TITLE);
        loadNav();
        loadStatic::html('root');
    }

    static function login()
    {
        loadHead(LOGIN_TITLE);
        loadNav();
        loadStatic::html('login');
    }

    static function main(){
        updateLoginStatus();
        if (cookie::get("isLogin") == "yes") {
            loadHead(MAIN_TITLE);
            loadNav();
            loadStatic::html("main");
        }else{
            header("Location:./?/");
        }
    }

    static function register()
    {
        loadHead(REGISTER_TITLE);
        loadNav();
        loadStatic::html('register');
    }

    static function language()
    {
        cookie::set("local_language", isset($_GET['set']) ? $_GET['set'] : "zh");
        $target_path = isset($_GET['from']) ? "./?" . $_GET['from'] : "./?/";
        $target_path = str_replace(",","&",$target_path);
        header("Location:" . $target_path);
    }

    static function logoff(){
        cookie::delete('isLogin');
        cookie::delete('nickname');
        cookie::delete('password-part1');
        cookie::delete('password-part2');
        cookie::delete('password-part3');
        cookie::delete('password-part4');
        cookie::delete('room_xcid');
        cookie::delete('send_mail_time');
        cookie::delete('username');
        header("Location:./?/");
    }
    static function choose_room(){
        loadHead(CHOOSE_ROOM);
        loadNav();
        loadStatic::html('choose_room');
    }
    static function goto_room(){
        if (isset($_GET['xcid'])){
            cookie::set("room_xcid",$_GET['xcid']);
        }else {
            cookie::set("room_xcid", "sch");
        }
        header("Location:./?/main");
    }
    static function back_room(){
        cookie::set("room_xcid","chat");
        header("Location:./?/main");
    }
}